package com.lzm;

import com.lzm.mapper.DepartmentsMapper;
import com.lzm.mapper.DoctorMapper;
import com.lzm.mapper.HosregisterMapper;
import com.lzm.pojo.Departments;
import com.lzm.pojo.DepartmentsExample;
import com.lzm.pojo.Doctor;
import com.lzm.pojo.Hosregister;
import com.lzm.utils.MybatisUtil;
import com.lzm.vo.QueryVo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring.xml"})
public class test {
    @Resource
    private HosregisterMapper hosregisterMapper ;
    @Resource
    private DoctorMapper doctorMapper;
    @Resource
    private DepartmentsMapper departmentsMapper;
    @Test
    public void test01(){
        QueryVo vo = new QueryVo();
        vo.setDoctor_name("仔");
        vo.setDoctor_keshi("急");
        List<Hosregister> hosregisters = hosregisterMapper.queryByVo(vo);
        for (Hosregister hosregister : hosregisters) {
            hosregister.setDoctor(doctorMapper.selectByPrimaryKey(hosregister.getDoctor_id()));
            hosregister.setDepartments(departmentsMapper.selectByPrimaryKey(hosregister.getHosR_keshi()));
            System.out.println(hosregister);
        }
    }

    @Test
    public void test02(){
        DepartmentsExample example = new DepartmentsExample();
        DepartmentsExample.Criteria criteria = example.createCriteria();
        List<Departments> departments = departmentsMapper.selectByExample(example);
        List<Departments> departments2 = new ArrayList<>();
        for (Departments department : departments) {
            Departments departments1 = departmentsMapper.queryById(department.getD_id());
            departments2.add(departments1);
        }

        System.out.println(departments2);
    }
}
